package greddy;

public class _04_122_买卖股票的最佳时机Ⅱ {
    public static int maxProfit(int[] prices) {

    	int sum = 0; // 利润
    	
    	for(int i = 1; i < prices.length; i++) {
    		if(prices[i] - prices[i-1] > 0) {
    			sum += prices[i] - prices[i-1];
    		}
    	}
    	
    	return sum;
    }
    
    public static void main(String[] args) {
    	int[] prices = {7,1,5,3,6,4};
    	System.out.println(maxProfit(prices));
	}
}
